﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;

namespace DAO
{
    public class ChiTietPhieuChi_DAO
    {
        private static ChiTietPhieuChi_DAO m_instance = null;

        public static ChiTietPhieuChi_DAO Instance
        {
            get
            {
                if (m_instance == null)
                    m_instance = new ChiTietPhieuChi_DAO();
                return m_instance;
            }
        }

        /// <summary>
        ///   them CT Phieu CHI
        /// </summary>
        /// 

        public bool ThemChiTietPhieuChi(string _maphieuchi, string _maphi, long _thanhTien)
        {
            try
            {
                SqlConnection cnn = SQLConnection.Instance.SqlConnection;
                SqlCommand cmd = new SqlCommand("ADD_CHITIETPHIEUCHI", cnn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("@MaPhieuChi", SqlDbType.NVarChar, 10);
                cmd.Parameters["@MaPhieuChi"].Value = _maphieuchi;

                cmd.Parameters.Add("@MaPhi", SqlDbType.NVarChar, 10);
                cmd.Parameters["@MaPhi"].Value = _maphi;

                cmd.Parameters.Add("@ThanhTien", SqlDbType.Money);
                cmd.Parameters["@ThanhTien"].Value = (decimal)_thanhTien;

                cmd.ExecuteNonQuery();
                return true;
            }
            catch (System.Exception ex)
            {
                return false;
            }
        }
    }
}
